//
//  GHHomeHeaderView.m
//  GodHorses
//
//  Created by Mac on 2017/11/14.
//  Copyright © 2017年 stoneobs@icloud.com. All rights reserved.
//

#import "GHHomeHeaderView.h"
#import "GHHomeDataController.h"
@interface GHHomeHeaderView()

@property(nonatomic, strong) UIView                     *videoView;
@end
@implementation GHHomeHeaderView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self configSubView];
    }
    return self;
}
#pragma mark --subView
- (void)configSubView{
    
    //广告
    self.adverView = [[STAdvertingScrollView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 200) andWithArray:@[@"img_banner_2",@"img_banner_1",@"img_banner_3"] handle:^(NSInteger num) {
        
    }];
    self.adverView.canAutoScroll = YES;
    self.adverView.pageControll.st_centerX = UIScreenWidth / 2;
    self.adverView.pageControll.st_bottom = self.adverView.st_height - 10;
    self.adverView.time = 3;
    [self addSubview:self.adverView];
    
    //新闻
    UIView * newsView = [[UIView alloc] initWithFrame:CGRectMake(0, self.adverView.st_bottom + 10, UIScreenWidth, 70)];
    newsView.backgroundColor = [UIColor whiteColor];
    UIImageView * goldImageView = [[UIImageView alloc] initWithFrame:CGRectMake(15, + 15, 40, 40)];
    [goldImageView st_showRightInsetLine:goldImageView.st_height insetx:-10];
    goldImageView.image = [UIImage imageNamed:@"main_paomadeng"];
    [newsView addSubview:goldImageView];
    self.newsCirculView = [[GHNewsCirculationView alloc] initWithFrame:CGRectMake(goldImageView.st_right + 15, 0, UIScreenWidth - 70, 70)];
    [newsView addSubview:self.newsCirculView];
    [self addSubview:newsView];
    
    //视频
    UIView * videoView = [[UIView alloc] initWithFrame:CGRectMake(0, newsView.st_bottom + 10, UIScreenWidth, 200)];
    self.videoView = videoView;
    [self addSubview:videoView];
    ZFPlayerView * playeView = [ZFPlayerView sharedPlayerView];
    self.playeView = playeView;
    ZFPlayerModel * model = [ZFPlayerModel new];
    model.placeholderImage = [UIImage imageNamed:@"video_preview"];
    model.videoURL = [NSURL URLWithString:@"https://video-cdn.suiyueyule.com/20171009122453-lsho_0whV8MTl1AfY1Xpv1DqoVz7.ts.mp4?auth_key=1510722944-0-0-c6224cd99e899028ff849e17ebbd62c4"];
    model.fatherView = videoView;
    [playeView playerModel:model];
    
    self.st_height = videoView.st_bottom + 10;
}
- (void)setVideoModel:(GHVideoModel *)videoModel{
    _videoModel = videoModel;
    
    ZFPlayerModel * model = [ZFPlayerModel new];
    model.placeholderImageURLString = videoModel.vedio_img;
    model.videoURL = [NSURL URLWithString:videoModel.vedio_url];
    model.fatherView = _videoView;
    [_playeView playerModel:model];
}
@end
